﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Model.WXshopBuiness;
using Xproject.Framework.Core.Repositories;
using Xproject.Framework.Utility.Extensions;

namespace Repository.WXshopBuiness
{
    public static class ProdSpecifationRep
    {
        public static ProductSpecification GetProdSpecifation(this IRepositoryAsync<ProductSpecification> repository, string specifationId)
        {
            Expression<Func<ProductSpecification, bool>> express = i => i.ProductSpecificationId == specifationId;           
            return repository.Query().Where(express).Select().FirstOrDefault();
        }
        public static List<ProductSpecification> GetProdAllSpecifations(this IRepositoryAsync<ProductSpecification> repository, string productId)
        {
            Expression<Func<ProductSpecification, bool>> express = i => i.ProductId == productId;
            return repository.Query().Where(express).Select().OrderByDescending(i =>i.Sort).ToList();
        }
    }
}
